package com.house.api.controller;

import com.house.common.result.Result;
import com.house.model.dto.HouseImageDto;
import com.house.model.vo.HouseImageVo;
import com.house.service.service.IHouseImageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/houseImage")
@Api(tags = "房屋图片相关接口",value = "房屋图片相关接口")
public class HouseImageController {

    @Autowired
    private IHouseImageService houseImageService;

    @DeleteMapping()
    @ApiOperation("根据房屋ID删除对应的图片")
    public Result removeHouseImage(@RequestBody HouseImageDto dto) {
        houseImageService.removeHouseImage(dto);
        return Result.ok();
    }

    @GetMapping("/{houseId}")
    public Result getHouseImageByHouseId(@PathVariable("houseId") String houseId) {
        List<HouseImageVo> houseImageByHouseId = houseImageService.getHouseImageByHouseId(houseId);
        return Result.ok(houseImageByHouseId);
    }

}
